﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseSet.Data;
using BaseSet.Logic;
using BaseSet.Entity;
using BaseSet.Framework;
using BaseSet.Entity.Common;
using BaseSet.Entity.Common.Text;
using BaseSet;
using System.Data;

namespace WebSite.Admin.SystemSet
{
    public partial class PasswordEdit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #region 提交密码
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Users uinfo = UserBase.GetCurrentAdminUser();

            string password = txtPassword.Text.Trim();
            string newpassword = txtNewPassword.Text.Trim();
            string reennewpassword = txtReenNewPassword.Text.Trim();

            if (string.IsNullOrEmpty(password))
            {
                Tools.Alert("请填写原密码");
                return;
            }
            if (string.IsNullOrEmpty(newpassword))
            {
                Tools.Alert("请填写新密码");
                return;
            }
            if (string.IsNullOrEmpty(reennewpassword))
            {
                Tools.Alert("请填写确认新密码");
                return;
            }
            if (newpassword != reennewpassword)
            {
                Tools.Alert("确认新密码输入不同");
                return;
            }
            if (Encrypt.Encode(password) != uinfo.Password)
            {
                Tools.Alert("原密码不正确");
                return;
            }

            uinfo.Password = Encrypt.Encode(newpassword);
            UsersHelper uhelper = new UsersHelper();
            uhelper.EditUsers(uinfo);
            Tools.Alert("密码修改成功");
            return;
        }
        #endregion
    }
}